package com.littlerpc.protocol.net.common;


import com.littlerpc.protocol.net.netty.server.NettyServer;

/**
 *
 * @author ChengPeng
 * @date 2017/6/18
 */
public enum NetProtocolEmum {

    /**
     * NETTY
     */
    NETTY(NettyServer.class);


    public final Class<? extends RpcServer> serverClass;

    private NetProtocolEmum(Class<? extends RpcServer> serverClass) {
        this.serverClass = serverClass;
    }

    private Class<? extends RpcServer> value() {
        return serverClass;
    }

    /**
     *获取匹配的数据
     * @param serverName
     * @return
     */
    public static Class<? extends RpcServer> getRpcServer(String serverName) {
        NetProtocolEmum[] services = NetProtocolEmum.values();
        for(NetProtocolEmum emum : services) {
            if(emum.name().equalsIgnoreCase(serverName)) {
                return emum.value();
            }
        }
        return NETTY.value();
    }

}
